Organizing the js code