Fixed bug that cause copy on passing reference as function argument