added rudimentary input validation