using closures as in Javascript