modify anonymous function to method