Bug fixing: Added check to session exists