changes die to throw exceptions instead