js bug fix for redirect