Cleaned up command handling