Fixed bug in lcm