Implemented Part 0 through Part 2 of Algorithm 

Signed-off-by: fisherjk <John@John-PC>