Updated logout function