implemented closures

sloppy coding fixed!