fixed small bugs and tested them