refactor API and add support for more instructions