improve session handler

improve session handler