Fix: move logic up