Finished Algo2.1