fixed stack overflow when swtiching modals