optimize cleanup