hexifying the numbers and cleaning up code