some futher optimization to doing things in one cycle