refactor to clean global namespace