Smarter xc6 function