Updated with suggestions from @willnoris.