Same code for both states. Now I just need to put all of that working code into a function.