shuffle code around to make a little more logical sense