Refactoring variable local error