fixed issue with static variable and threads dont mix them.