Evolution of substrate specificity in a retained enzyme driven by gene loss