Use a generator instead of returning a list
Remove unused code