fixed not working alg