updated psuedoCode