delete function works fine now