tested code and fixed bugs