implementing PAM algorythm - one step for now