These three lines could be reduced using list comprehension but I guess it's fine as it is?