Improve responsiveness with better algorithm