Improved thread parallel implementation