changing anonymous function to normal function