fixed some bug with redirecting