cleaned up code for AI