Corrected if loop for X check