implementation of linear interpolation