Rewrote p1 to not use 'last'