Replace string library call with local function