Fixed data read issue and added error reporting