Moving an object relative to mouse

Making an object to follow the mouse is easy

public static void MoveObject(GameObject gameobject)
	RaycastHit hit = CastRay(~(1 << 8));
	gameobject.transform.position = hit.point;

But this code makes it so the objects always under the mouse, what I need done is the object to move relative to the mouse. In otherwords instead of the object matching its coordinants to the mouse coordinates, it needs to match its movement to the mouse movement. (Object may or may not be under mouse, but still move left if the mouse is dragged left)

Does this all makes sense?

save last frame mouse pos and current frame mouse pos. subtract last frame pos from current pos to get delta pos. add delta pos to any object’s transform.position