Algorithms improvement