Extract code that checks a command