Use fromMaybe with an error message instead of fromJust.