Use locals explicitly and return proper exit code