updated code in readdata.c