fixed substring error