refactoring for proper responses