Bug fix: getting the element of the list the right way; formatted some
unreadable code