Fixed crash on invalid input