modify data structure and fix test cases