Rework flax logic