add debug to check intermediate result