get algorithm right