completed and tested set method; refactored typechecking