Refactored code to employ javascript closure