add logout, fix some bug