Feature/refactor relation

/to @ritch 
I'll fix it.