bug to used local variables in other functions