oops, copied too much
restructure code to move things out of the nmi interrupt