Added threads in a quick and dirty way