[BUGFIX] Check variable before accessing