changed ai with pseudocode