cleaned up interpolate function