Tweaking example code to match formula