refactored handler into named function