added redirect in case user not logged in
fixed some bugs