Fixed thread problem