putting in this section of the algorithm that i completely neglected