Fix python 3 implementation

Python 3 can not compare NoneType and int.