Added custom query for related values, fixes issue #202