please consider removing the number of globals by refactoring if possible