Added checking to variable declaration to make sure that it is legal.