Added update_nonzero function to replace decrement and increment nonzeros in binary