There's quite a lot of repeated code; could we pull some out into helper methods?