changed structure of the algorithms