added emergency code