use faster algorithm