javascript reorganization