almost done,need debug