adjusting code to allow for validation of input