implemented control flow