NULL check for result.
free result when finished