adding beginning of closure
almost done: just a couple more bugs