optimize js structure