added read and write functions; rewrote lookup to reflect this.