Fixing algorithm.