refactored track reading and writing into separate classes