Made expand-to-line simpler

Changed the functionality based on feedback.
Cleaned up code.