Latest version of Algorithm with bugs