Rewrite this a bit.