updated delete logic