refactored hex class