The `log` and `createSession` code is duplicated and should be pulled out into a commonly called method.