refactored out file ops