refactor API methods in separate context