Multiline commands fix: make the check a function

Make the multi line command check a function to be called in different places.