made changes to p==2 as well