Scoping issues

Prior to this commit n was always 1