now controling on XY with full refactored code