add Optimization base on the time complexity