working on logging errors properly
added proper logging of errors in data files