add logout and fixed some bug cause of generate header