refactor Cmd and fileReading