Restructuring js