moved user state function out of app.js