Added check for valid QOS (0 or 1)