fixing entity deletion issue