replace a map and getOrElse on an option with a fold