More javascript refactoring~!