move re out of loop to boost performance