Fixed possible substring error