Added helper function for command handling.