logging cleanup of file better