Relation code refactored a tiny bit