moving variables to lower scope