added relational code to models