Added invalid command detection

Added invalid command detection and removed the blank command detector
as that was buggy.