added debug lines to track program flow