fixed a few bug added in the last commit