Added code of Algorithm, part II