some changes to speedup program