Fixing error where session ends