got rid of line counter and checking widgetlist.size() directly
got rid of compiler warnings