Added barriers correctly

Fixes #1406
Combine the condition with the previous one