fix bug with deleting entities