replaced String.substring() with String.slice() as it's behavior is more determinate