tried moving self.redirect above apis to see what happens