correcting null pointer in UI thread issue