refactoring request handling in the separate file