experimenting with program flow in javascript