Optimises lousy code in 0f9d11ac thanks to @caitp