adding original code taken from http://www.coneco.net/widget/indexjs/list_index.html