Make for loop work with lists properly