First pass at reimplementing using closures