added import sys for exit calls