simplified flow, replaced NULL with null