Extract out local function