updating 2's generation algo