Added null check in study deletion