Refactor API request