WROTE AI pseudocode
ADDED AI helpers