Why only move generation of the key down inside this block?