add local function -- not work well