copying in Ed's code