Move func def out of func for better performance.