psuedocode for states