Added check for user logged in