fixed some bugs, program can run