I don't think you need to create a function enclosing this logic inside the closure function