local in an if statement loses content when exiting if statement...
also removed a bit unnecessary code