Refactor relationships controller