correct errors in substring