Code refactoring for function in closures

Code refactoring is performed affecting those functions that define inner functions by implementing the Module Pattern