add some idiot proofing

Add some checks on the inputs.