fix the bug for function