added 2 modes for r/w