modify speed up code