switching order of these calls, bug uncovered by tests