fixed error if no defined department in database