Fixing bug in relationship table