Small optimization on calculating los