EEPROM code refactored