Fix error with accessing db
Fix error in database counter