cleaned up the code for creating files