more refactoring to make sure response is handled once and only once