Written in pure JavaScript