a couple of helpers, and merge