Remove function declaration from loop