in reply to how to improve this?
To find the bottleneck I'd recommend reading the thread RFC: Profiling your code..
When you know which part is the slowest one you can start to optimize it. But don't guess, you'll be wrong (usually).