while; fixed var declarations; added assignments