The reordering of this var and function aren't (or shouldn't be) significant--I just wanted the vars to be at the top and the function closer to where itw as used.