Updated for validations and error handling.