fixed: potential sql error when deleting records