revised delete logic