added changes from TaoW