inverter refactored so it can listen to wire events