Copied Charles' latest code.