adding debug stuff and fix for an error