restructuring code. It's in the wrong order currently.