Fix the instance of template object in closure