Re-organise JS