change code to use state level objects