Using my own medicine to clean up the groups of code used in areas of
the extension
Tidy up of the lineUpFunction function so that it's easier to read and
smaller extracted code out to functions to make it easier to read