p1 and p2 components sometimes become longs. modulo operation returns them to ints