minor changes for speed up code