Adding what I have of Peter's code