Refactor interpolation function.