more cleanup and create file code