Slightly simpler javascript