restructuring javascript files