modified debugging function