moving some code around. silly bug