moved definition of n to above the location where it's used