added exit code to redirection when user isn't logged in, commented out unused code, move initiation closer to actual usage.