Changed isAuthenticated variable to function.