update version
fix a few logic issues