Fix delete logic