Refactor methods for defining relations