Feature/refactor relation

/to @ritch