moved the reader code into its own module