Finished Algo 1