Thanks for the code, Upgraded. I tried it on AA flight JFK/MAD (not codeshare) within date parameters but it wouldn't work. Code worked fine for return flight, only the return flight was through MIA and cost more (with 10% off) than the direct fare MAD/JFK. I therefore didn't use code. Maybe someone else will have more luck than me.
Thanks anyway!