Fixed a wrong check
Fixed a reversed return value