moved to classes to encapsulate file operations