Added some more input validation