Further algorithm refining