fix variable scope
fix toggle running