changed [] operator to work as a mutator as well as an accessor; added preliminary error handling