fix compiling errors and compile code