fix the TypeError: Cannot call method 'toHexString' of undefined