inprove algorithm