minor refactor, and comments, and added one missing exception