fix bug during cleanup