code cleanup and removed ui delay