Edited to validate user inputs where required