adding invalid command detection