fixed {w} to {{w}} in Figure 1 algorithm