Cleaned up code a bit, added relationship