better exception handling, random hex generator