fix substring error