fix control flow