change a few functions so they can be pure