javascript nested closures - small fix