simplified command matching code