Fix bug with database