Trying to fix timeout thread problem