Clean the serialised data - wrap the AI in a function