all this funky closures and other functional beasts