Moved environment variable check to datadir path