minor refactoring, introduce debug lines