Could you use Tools::substr() instead of substr() please ?