Refactored code to work for all Is. Added test for X