Added check for compatibility of X and Y.