technique for stack borrowed from printStackTrace()