finished refactor to global