refactoring to solve closure
refactor to fix Closure problem