corrected control flow