They will still be removed (and copied to paidshares) if both values for the share were paid during this run. An issue here is that since you exclude shares that have been marked as paid from the select query, they won't get moved to the paidshares table if part of the balance was paid during a previous run. This could leave a bunch of fully paid shares in the shares table. But that seems intentional given how you're excluding them to begin with?