Fixed return value checking logic.