some changes added debug code