Added error handling for sentence parsing