operator[] returns invalid results