Fixing some js issue with multiple elements