increased checks for invalid input