fix recursive closure function