There's some code duplication in there.  :(