Remove global variable and fix dependency