reworked control flow