Neatened up some code