Refactored the reader to make sure it is thread safe