refactoring of resourceToModel (work in progress)