missing null checks for doc and source