addressed @bitiotic comment to use local variable