fixed several code errors