improving regex matching