We can not give an correct answer without seeing the algorithm, but even this could only a guess. (Maybe you introduced a bug that has nothing to do with the new algorithm)

You will get the best answer this way:

1.) Run the program with a profiler and check were the bottleneck is (you will be suprised )
2.) Optimize the bottleneck.
3.) Repeat 1.) + 2.) until the performance is ok.