replace table and sub in func