removed a bunch of for loops to replace with list comprehensions