moved a global object to the only method that used it and formatted ai code
formatted methods and statements to follow the same coding conventions