bug caused by incorrect scope