Refactor get_hex to reduce complexity

Refactored the get_hex method in order to reduce the overall complexity by removing the case statement.