Add parsing protection against invalid input