Fix redirect logic