Refactor API responses