had to put UI code in dispatch block