Redone Older Code that was lost. It now works

done and working. AI-wise