add CMakeLists.txt file and corrections to algo