moving functions around
cleaning up a bit