bit of a rewrite