refactored i2c code and added i2cget support