debugged readin routine