Convert setup from closure to simple function and combine advance with duplicate code later