Improved algorithm

-reduced calculation time
-implemented XmlHttpRequest response