Fix UI flash issue