Implemented a portion of the algorithm

Implemented a portion of the algorithm