changed anonymous function to named function