Fixed error in toHexCode