Restructruing javascript files