refactored the building of the lists