Changed for loop to append to speed up code(?).