refactor to conform jsLint