Threading part... doesn't work, need to rewrite