Reworking this a bit, initial solution was awkward.