this scary regexp is used twice, we could move it out to somewhere else maybe.