Handlers code refactoring