tested and fixed bugs