2009 code, need to be rewrote now since google engine changed