Fixed the bug which causes duplicate functions to be generated