Added relationship part of algorithm