Refactor api responses