javascript reorganized