first pass at write functionality