before deleting items, it is now checking for null