how can I pass a variable between three functions running in series?