cleanup use of anonymous function