Revert "Replaced anon function with class function"

This reverts commit a1bf21aba29be4f9bc11a474038de34b8be1b805.