Removed dependence on global variables