add if statement to check whether new doc or uploaded doc