Added conditions so program won't crash when invalid data is entered in the variable fields