Reimplementing logic for the flow of program