implemented basic reader and more refactoring