fixes #28
slightly refactored, imprived logging