Reducing size of loop in p9