moved around some code