added error checks for inputs