fixing some really silly errors

 Moving variable declarations into proper scope. Yikes.