implementation with lot of debugging output