fix typo and scope variables