fixed bugs and tested all methods