added some code that allows it to work with any line length