refactor request handler for mongoose