Removing global variable creation

Keeping code consistent and avoiding some global variable creation.