modification on compare.py to deal with empty issue