fix variable undefined error