Pure JS solution