rewritten function to print hex numbers