move functions around a bit