changed place of detecting and redirecting if user is not log on (issue #3)