Fixed a bug with input validation