refactor login. chat demo works now