Bit of a rewrite just for fun