fixing database persisting bug