Corrected bug with substring