fixed local vars scope