Make copy function more robust
fix bug consolidating optimal results