added redirect and logging