attempted fix for strange errors with threading