Fixed a bug in input validation