count and delete code