fixed bug on reference and copying