Added JavaScript function closures