drag a plane without jumping to center

I want to drag a plane around in world space, and the script does work so far, but the plane always jumps with its center to the mouse position. I want to grap it just anywhere in it and then drag it to another position and again. I guess, I have to calculate an offset, but have no idea how to do this – I tried a lot, can´t get it… I attached this to a plane

using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;

public class drag : MonoBehaviour {

private Vector3 mousePosition;
private Vector3 pos;
bool dragit;
float dist = 10;
private void OnMouseDown()
{
    dragit = true;
}
private void OnMouseDrag()
{
    mousePosition = new Vector3(Input.mousePosition.x, Input.mousePosition.y, dist);
        pos = Camera.main.ScreenToWorldPoint(mousePosition);
    transform.position = pos;
}
private void OnMouseUp()
{
    dragit = false;
}

}

I think I have figured it out. You need to get a point on your initial click, relative to the current transform position. Then offset it by that while it’s moving. Here is the code:

private Vector3 mousePosition;
private Vector3 pos;
private Vector3 initialPos;

bool dragit;
float dist = 10;
private void OnMouseDown() {
    if (Input.GetMouseButtonDown(0)) {
        mousePosition = new Vector3(Input.mousePosition.x, Input.mousePosition.y, dist);
        initialPos = Camera.main.ScreenToWorldPoint(mousePosition) - transform.position;
    }
    dragit = true;
}
private void OnMouseDrag() {
    mousePosition = new Vector3(Input.mousePosition.x, Input.mousePosition.y, dist);
    pos = Camera.main.ScreenToWorldPoint(mousePosition);
    if(dragit)
        transform.position = pos - initialPos
}
private void OnMouseUp() {
    dragit = false;
}