edit js to avoid repeating