added logout
fixed multiple header writes