fixing buggy on/off - added debug codes