Simplified thanks to @TomNomNom