some cleanup and now spits out json results which can be displayed in a datatable.