psedocode for conditions of stages