add 'use strict' and fixed undeclared variables