Fix substring error