fixed logical flow