fixed all the bugs that mihai created