Thanks for all the help.
I realized that It may not be that portion of the code thats causing a CGI Timeout. I'm pretty sure its because of the "O.O" part in the symbol "AIDO.OB" thats causing a breakage somewhere in my script. ALl other symbols work fine, and if I try adding a "." anywhere inside a symbol, it will stall. So for ex. IF I tried using "BLAH.SYMB" then it will still stall.