moved reader implementation to separate file