working flush & merge tmp files