polishing code with js hint