Util fix: boundary condition on replace routine