fixed issue with threading