improve calculate speed