Created functions readByte and writeByte to prevent code redundancy