Added some validation and error handling.