Still trying to fix bug with delete() function. Might have to revert to earlier version