private functions and javascript handler functions refactor