Added code to check for invalid commands