updated using more clever stuff.