Converted to Vanilla JS