updated main 1 with boolean flag to begin processing