lots o' vanilla  javascript
fixed merge conflicts