Fix conditional loop