Updated it with new regex and some optimizations.