algorithm fixed