add more client input checking, add some comments