refactor req and res