I'm doing this, but I have a feeling this is quite messy. Maybe I should re-factor the paragraph below and then describe going by line numbers?