improved blank line detection