refactored js using .eq()