fixing calculation error on table delete