fixed scope reference error when modal.remove() is called