Pseudocode for moveState