refactor the load method and use a flatmap instead