added small debug helper
added session check before accessing session data