guard against bad inputs