added extra check for empty commands