fixed bugs and errors