Updated to use more robust gender check