Fixed isValidCommand to handle correctly.