Moved each command handler into its own function