Added check for empty cases.