refactored relations implementation to keep self sane