bugs fixed: range of replace and insertion