minor edits, then updated validation and error handling