algorithm to generate data structure added