checked the code with jslint