Neatened up this for loop a bit