added better algorithms