merge Peter code