reorganize javascript