update the delete_if contions to fix errors

errors:
`/': divided by 0 (ZeroDivisionError)
undefined method `*' for nil:NilClass (NoMethodError)
undefined method `/' for nil:NilClass (NoMethodError)