fix a lot of bugs and implement methods