with thread support but not 100% working