clean up and simplify a bit