Updated with feedback from cgay.