added validation function to ensure the user is inputting data/valid data