cleanup code: session init and internal server error
clea
cleanup code and add logs