Refactor to allow different easing functions.