Broke out code to a seperate file flow.go