Refactored function name to meet naming standard
Refactored code to move global variables to application layer, held within a struct