Updated to actually work with deferred statements (with closures)