fixing error handling/validation