added wd's code