fix bugs and add function compile