change link function, make more flexible