Peter and Rich's solutions.