fix js error and redirects