more efficient regex code