Fixed funny code flow