added logout only when logged in