fixing issue with pipe (|) after bracket (])
refactoring checking for pipe inside brackets