exception is added to the result
refactorings and bugfix