fixing data read-in function