anonymous function handling to replace tablenames