refactored responses into functional code