Factor out hex code