reading in thread instead of main