Protecting against bad inputs