Fixed #3216, added toString() before using slice()