added psuedocode-algorithm