fix variable scope
fix toggle running
use lodash helper functions instead of ugly typeof calls