substring bugfix