redirecton logic bug fix