fixed pass variable by reference error