fixed bugs, there may be more