adding proper threading