Bug fixed for the delete function