Algorithms implementation improvement