* minor variable refactoring
 * refactoring loops for a massive speed up (at the cost of memory usage