fix deadlock problem with on and off
new version