Fix with changing mode, check if reference not empty