Improve peter code