Scoping vars and simplifying EC bit function