added some checks for user input