Changed how the function is defined
Removed global dependencies