updated psuedocode