make use of new data structure and bug fix