major refactoring to handle previous and next line emptiness indicators