ICM algorithm and other functions used in ICM