modify some function to local function