you can avoid string copy in this solution