check if doc exists first