Added check for empty category