Fixed bug with undefined session