fix bug
complete code function