Helper function for both of these.