less memory
now algorithm is all right