fixed bugs && did unit testing