Moved commands into their own function