threads work perfectly for small inputs