make input parsing more robust