Removed dependency on global variable