Translated the pseudocode, does not compile! (the latex code)