Refactor

- removed code multiplication for exception handling
- re-introduced dims() which got lost somehow in the previous version