move this after the ts == nil check