replace toString with instanceof
update to handle all draft4 specs
modified to conform to draft4