Refactor of message_commands()