merge store loop into calculation loop
merge store loop into calculation loop