This rather complex pair of lines is occurring a lot...maybe worth encapsulating?