some changes on algorithms