cleaning up code and did some work with relationships