v1.1 improved algorithm