Improve String.slice implementation