moved update code into it's own thing