Moved some unnecessary compuations out of loop
Added timings