cleaned up file opening