error and invalid input handling