function to detect a command