fixed bug in analog_write function