bug fixing and typo correction