added logic for handling map relations