modified the termination condition of swap phase in PAM.java