Refactored reactions to commands into external functions