made more reliable with invalid commands and added testing