fix bugs, simple version is done.