Moved hexToRgb function to top

Thanks for @djekl for the suggestion