proposed algorithm finished