fixing check for null session