Move function generationg filter to plugin file and format the code a little