better bounds-checking, also fix DOM call