refactering to include elements and changing the data structure