add debugging + bugfix