fixed control flow logic