introduce command recognition utility; refactor pair