added database flush and reset mechanism