added before after section cleaned up temp and file lock