toread undefined index fixed