moved logic around a little bit.