outsource more code to procedures

hopefully i2c_write is getting more clear