add redirect, clean up code