Added scope and corrected vaiables for private keys