move all to anonymous function