fix replace variables: check for None type