Fixed pseudocode