code has been refactored and bug with ui element widget has been fixed