fix nation bug
split table update code into separate function
clean up whitespace