latest version with Nick's last corrections