Fix broken logic