part i optimization of code 5398593