Optimized the computation slightly