Put logic from logwindow to errorcontrol