Changed hex converter into a function to fit requirements.