Switched p.up and p.down to p.u and p.d.