some error checks, fixed an 'elif' typo