improve speed and more re-arrangement