fix logic
removed implicit global variable