solving on multiple threads